<template>
  <el-dialog :title="title" :visible.sync="dialogVisible">
    <div class="Dialog">
      <div class="content">
        <div class="tableList flex">
          <div class="tableList_title">所属厂区</div>
          <div class="tableList_con">
            <el-select v-model="List.所属厂区" clearable allow-create filterable placeholder="请选择所属厂区">
              <el-option v-for="item in factoryList" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </div>
          <div class="tableList_title">物资类型</div>
          <div class="tableList_con">
            <el-select v-model="List.物资类型" clearable allow-create filterable placeholder="请选择物资类型">
              <el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </div>
        </div>
        <div class="tableList flex">
          <div class="tableList_title">物资编号</div>
          <div class="tableList_con">
            <el-input placeholder="请输入物资编号" v-model="List.物资编号" clearable />
          </div>
          <div class="tableList_title">物资名称</div>
          <div class="tableList_con">
            <el-input placeholder="请输入物资名称" v-model="List.物资名称" clearable />
          </div>
        </div>
        <div class="tableList flex">
          <div class="tableList_title">规格</div>
          <div class="tableList_con">
            <el-input placeholder="请输入规格" v-model="List.物资规格" clearable />
          </div>
          <div class="tableList_title">单位</div>
          <div class="tableList_con">
            <el-input placeholder="请输入单位" v-model="List.物资单位" clearable />
          </div>
        </div>
        <div class="tableList flex">
          <div class="tableList_title">数量</div>
          <div class="tableList_con">
            <el-input placeholder="请输入数量" v-model="List.物资数量" clearable />
          </div>
          <div class="tableList_title">所在位置</div>
          <div class="tableList_con">
            <el-input placeholder="请输入所在位置" v-model="List.所在位置" clearable />
          </div>
        </div>
        <div class="tableList flex">
          <div class="tableList_title">开始日期</div>
          <div class="tableList_con">
            <el-date-picker v-model="List.物资开始日期" type="date" placeholder="选择开始日期" />
          </div>
          <div class="tableList_title">报废日期</div>
          <div class="tableList_con">
            <el-date-picker v-model="List.物资报废日期" type="date" placeholder="选择报废日期" />
          </div>
        </div>
        <div class="tableList flex">
          <div class="tableList_title">负责人姓名</div>
          <div class="tableList_con">
            <el-input placeholder="请输入负责人姓名" v-model="List.负责人姓名" clearable />
          </div>
          <div class="tableList_title">负责人电话</div>
          <div class="tableList_con">
            <el-input placeholder="请输入负责人电话" v-model="List.负责人电话" clearable />
          </div>
        </div>
      </div>
      <div class="dialog-footer">
        <div class="btns flex">
          <div @click="addEventListener">确定</div>
          <div @click="dialogVisible = false">取消</div>
        </div>
      </div>
    </div>
  </el-dialog>
</template>
<script>
import axios from "axios";
export default {
  props: {
    title: String,
    List: {
      type: Object,
      default: () => ({
        所属厂区: "",
        物资类型: "",
        物资编号: "",
        物资名称: "",
        物资规格: "",
        物资单位: "",
        物资数量: "",
        所在位置: "",
        物资开始日期: "",
        物资报废日期: "",
        负责人姓名: "",
        负责人电话: "",
      })
    }
  },
  data() {
    return {
      dialogVisible: false,
      url: "http://10.199.98.2:8086/3DInterface_D/Business/EmergManage",
      factoryList: [],
      typeList: [],

    };
  },
  watch: {
    'List.所属厂区': {
      async handler(newVal) {
        // this.List.物资类型 = ""
        await axios.get(this.url + `/Platform/yjwz_bb_wzss?factoryArea=${newVal}`).then(res => {
          const options = res.data.data.map(item => ({
            value: item["物资类型"],
            label: item["物资类型"]
          }));
          this.typeList = options;
        }).catch(err => {
          console.log(err);
        })
      },
      deep: true
    }
  },
  methods: {
    addEventListener() {
      this.$emit('addEventListener', this.List,this.title)
      this.dialogVisible = false
    },
    async getList() {
      await axios.get(this.url + `/Platform/yjwz_bb_cqss`).then(res => {
        const options = res.data.data.map(item => ({
          value: item["所属厂区"],
          label: item["所属厂区"]
        }));
        this.factoryList = options;
      }).catch(err => {
        console.log(err);
      })
    },
  },
  mounted() {
    this.getList()
  },
};
</script>
<style lang="scss" scoped>
::v-deep .el-dialog {
  width: 1000px;
  height: 610px;
  margin-top: 270px !important;

  .el-dialog__header {
    padding: 7px 16px;
    height: 36px;
    box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.05);

    .el-dialog__title {
      font-family: "Source Han Sans CN";
      font-size: 16px;
      font-weight: 900;
    }

    .el-dialog__headerbtn {
      top: 10px;
    }
  }

  .el-dialog__body {
    padding: 0;
  }

  .Dialog {
    width: 1000px;
    height: 542px;
    font-family: "Source Han Sans CN";
    font-style: normal;

    .flex {
      display: flex;
      justify-content: space-between;
    }

    .content {
      margin: 32px auto;
      width: 920px;
      height: 454px;
      border-top: 2px solid #165DFF;
      border-bottom: 2px solid #165DFF;

      .tableList {
        width: 920px;
        height: 75px;
        border-bottom: 1px solid rgba(22, 93, 255, 0.50);

        &:last-child {
          border-bottom: none;
        }

        .tableList_title {
          width: 126px;
          height: 75px;
          line-height: 75px;
          padding-left: 18px;
          background: rgba(22, 93, 255, 0.05);
        }

        .tableList_con {
          width: 334px;
          padding: 8px 18px;

        }
      }
    }

    .dialog-footer {
      width: 1000px;
      height: 56px;
      box-shadow: 0px -5px 10px 0px rgba(0, 0, 0, 0.05);
      padding-top: 13px;

      .btns {
        margin-left: 811px;
        width: 124px;
        height: 32px;

        div {
          width: 58px;
          height: 32px;
          line-height: 32px;
          text-align: center;
          border-radius: 4px;

          &:nth-child(1) {
            background: #165DFF;
            box-shadow: 0px 2px 0px 0px rgba(0, 0, 0, 0.04);
            color: #FFF;
            font-size: 14px;
            font-weight: 700;
          }

          &:nth-child(2) {
            border: 1px solid #165DFF;
            color: rgba(22, 93, 255, 0.70);
            font-size: 14px;
            font-weight: 350;
          }

          &:hover {
            cursor: pointer;
          }
        }
      }
    }
  }
}

::v-deep .el-input--medium .el-input__inner {
  height: 58px !important;
  line-height: 58px !important;
  width: 290px !important;
  border: none;
}

::v-deep .el-date-editor.el-input,
.el-date-editor.el-input__inner {
  width: 290px !important;
}
</style>
